﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class admin_newstype : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["login"] == null)
            {
                Response.Redirect("login.aspx");
            }
            else
            {
                rptdatabind();
            }
        }
    }
    private void rptdatabind()
    {
        YqhData obj = new YqhData();
        rptnewstype.DataSource = obj.FillDataSet("select * from newstype order by tid");
        rptnewstype.DataBind();
    }
    protected void rptnewstype_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        YqhData obj = new YqhData();
        switch (e.CommandName.ToLower())
        {
            case "del":
                string sql1 = string.Format("delete newstype where tid={0}",e.CommandArgument);
                string sql2 = string.Format("delete news where ntypeid={0}", e.CommandArgument);
                obj.ExecuteSql(sql2);
                obj.ExecuteSql(sql1);
                rptdatabind();
                break;
        }

    }
}
